package com.dingding.gmall.order.controller;

import com.alipay.api.AlipayApiException;
import com.dingding.gmall.order.service.PayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author liugongding
 * @description:
 * @date 2022/4/1 3:33 PM
 */

@Controller
public class PayController {

    @Autowired
    private PayOrderService payOrderService;

    @ResponseBody
    @GetMapping(value = "/payOrder", produces = "text/html")
    public String payOrder(@RequestParam("orderSn") String orderSn){
        String html = null;
        try {
            html = payOrderService.pay(orderSn);
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
        return html;
    }

}
